package com.gwt.tirso.gymkhana.server;

/*
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.google.gwt.user.client.rpc.IsSerializable;
import com.gwt.tirso.gymkhana.client.Person;


public class JDBCPersonDAO implements IPersonDAO, IsSerializable {

	private Connection c;
	
	public JDBCPersonDAO() {
	       c = ConnectionManager.getInstance().checkOut();
	}
	
	protected void finalize() {
	       ConnectionManager.getInstance().checkIn(c);
	}

	
	@Override
	public void insertPerson(Person p) {
		
		PreparedStatement stmt = null;
		String sql = "INSERT INTO Person ( id, name, email, age, nick, password, country, city) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
        try {
            stmt = c.prepareStatement(sql);
            stmt.setString(1, p.getId());
            stmt.setString(2, p.getName());
            stmt.setString(3, p.getEmail());
            stmt.setFloat(4, p.getAge());
            stmt.setString(5, p.getNick());
            stmt.setString(6, p.getPassword());
            stmt.setString(7, p.getCity());
            stmt.setString(8, p.getCountry());
            stmt.executeUpdate();

	        } catch (SQLException e) {
	            System.out.println("Message: insertPerson: " + e.getMessage());
	            System.out.println("SQLState: " + e.getSQLState());
	            System.out.println("ErrorCode: " + e.getErrorCode());
	        } finally {
            try {
                if (stmt != null) {
                    stmt.close();
                }
            } catch (SQLException e) {
            }
	        
	        }
	}

	/*@Override
	public Person selectPersonByEmail(String email) {
		PreparedStatement stmt = null;
		String sql = "SELECT * FROM Person WHERE email = ?";
		ResultSet result = null;
		Person pers =  new Person();
		try{
			stmt = c.prepareStatement(sql);
			stmt.setString(1, email);
			result = stmt.executeQuery();
			if(result == null){
				return null;
			}
			result.next();
			pers.setId(result.getString("id"));
			pers.setName(result.getString("name"));
			pers.setAge(result.getInt("age"));
			pers.setNick(result.getString("nick"));
			pers.setPassword(result.getString("password"));
			pers.setEmail(result.getString("email"));
			pers.setCountry(result.getString("country"));
			pers.setCity(result.getString("city"));
        } catch (SQLException e) {
            System.out.println("Message: SelectUserByEmail: " + e.getMessage());
            System.out.println("SQLState: " + e.getSQLState());
            System.out.println("ErrorCode: " + e.getErrorCode());
        } finally {
        	ConnectionManager.getInstance().checkIn(c);
            try {
            	if (result != null)
            		result.close();
                if (stmt != null)
                    stmt.close();
            } catch (SQLException e) {
            }
        }	
        return pers;
	}*/
/*
	@Override
	public Person selectPersonByEmailAndPass(String email, String pass) {
		PreparedStatement stmt = null;
		String sql = "SELECT * FROM Person WHERE email = ? AND password = ?";
		ResultSet result = null;
		Person pers =  new Person();
		try{
			stmt = c.prepareStatement(sql);
			stmt.setString(1, email);
			stmt.setString(2, pass);
			result = stmt.executeQuery();
			if(result.next()){
				pers.setId(result.getString("id"));
				pers.setName(result.getString("name"));
				pers.setAge(result.getInt("age"));
				pers.setNick(result.getString("nick"));
				pers.setPassword(result.getString("password"));
				pers.setEmail(result.getString("email"));
				pers.setCountry(result.getString("country"));
				pers.setCity(result.getString("city"));
			}else{
				return null;
			}			
        } catch (SQLException e) {
            System.out.println("Message: SelectPersonByEmailAndPass: " + e.getMessage());
            System.out.println("SQLState: " + e.getSQLState());
            System.out.println("ErrorCode: " + e.getErrorCode());
        } finally {
        	ConnectionManager.getInstance().checkIn(c);
            try {
            	if (result != null)
            		result.close();
                if (stmt != null)
                    stmt.close();
            } catch (SQLException e) {
            }
        }	
        return pers;
	}

}
*/